<?php

//绑定域名
$route_domain = config_cache('host_server.domain');
$route_path = config_cache('host_server.path', '/host_server');

if ($route_domain) {

    $route = Route::domain($route_domain);
} else {
    $route = Route::prefix($route_path ?: '/host_server');
    // dump($route_path);
}

$route->namespace('Front')->group(function ($route) {
    $route->get('/', 'IndexController@index')->name('index');

    //域名
    $route->group(['prefix' => 'domain','as'=>'domain.'], function ($route) {
        $route->get('/', 'DomainController@index')->name('index');
        $route->post('/search', 'DomainController@search')->name('search');

    });

    // 基础价格 PC
    $route->get('/base_price','BasePriceController@index')->name('baseprice.index');
    // 基础价格 手机
    $route->get('/base_price/mobile','BasePriceController@mobile')->name('baseprice.mobile');
    $route->get('/mainserver','MainServerController@main')->name('mainserver.main');

    $route->get('/mianserver/getinfo','MainServerController@get_info')->name('mainserver.getinfo');
    $route->get('/mianserver/getmemory','MainServerController@get_memory')->name('mainserver.getmemory');


    $route->get('/page/{id}.html', 'IndexController@page')->name('page');
    //所有产品
    $route->get('/good.html', 'GoodController@good')->name('good');
    //产品，北美，亚洲
    $route->get('/good-{id}.html', 'GoodController@index')->name('good.index');
    //详情
    $route->group(['prefix' => 'good'], function ($route) {
        $route->get('/{id}.html', 'GoodController@show')->name('good.show');
    });
    //提醒付费采集
    $route->get('api/system/collect', 'CollectController@index')->name('api.system.collect');
    $route->get('api/domain/collect', 'CollectController@domain')->name('api.domain.collect');
    //注册和登录
    $route->group(['prefix' => 'auth'], function ($route) {
        $route->get('login', 'AuthController@login')->name('login');
        $route->get('forget', 'AuthController@forget')->name('forget');
        $route->get('rest', 'AuthController@reset')->name('reset');
        $route->post('auth', 'AuthController@auth')->name('auth');
        $route->get('regist', 'AuthController@regist')->name('regist');
        $route->get('login_out', 'AuthController@loginOut')->name('login_out');
        $route->any('/api/callback/{type}', 'AuthController@callback')->name('auth.callback');
        $route->get('/api/{type}', 'AuthController@three')->name('auth.three');

    });
    //API
    $route->group(['prefix' => 'api', 'as' => 'api.'], function ($route) {
        //发送邮箱验证码
        $route->post('/email/code', 'ApiController@emailCode')->name('email.code');
        $route->post('/good/system', 'ApiController@system')->name('good.system');

    });

    $route->group(['prefix' => 'user', 'middleware' => 'host_server_auth'], function ($route) {
        $route->get('/', 'UserController@index')->name('user');
        //购买主机
        $route->post('/buy/good', 'UserOrderController@buyGood')->name('user.buy.good');
        //购买域名
        $route->get('/buy/domain', 'UserOrderController@buyDomain')->name('user.buy.domain');

        $route->post('/buy/domain/post', 'UserOrderController@buyDomainPost')->name('user.buy.domain.post');

        //充值
        $route->get('/recharge/{type}', 'RechargeController@index')->name('user.recharge');
        $route->post('/recharge/{type}/post', 'RechargeController@recharge')->name('user.recharge.post');

        //会员设置
        $route->get('/seting/{type?}', 'UserController@seting')->name('user.seting');
        //会员操作
        $route->post('/handle', 'UserController@handle')->name('user.handle');

        //服务器订单
        $route->get('/order', 'UserController@order')->name('user.order');
        $route->get('/order/domain', 'UserController@orderDomain')->name('user.order.domain');

        //对账单信息
        $route->get('/bill/{type}', 'UserController@bill')->name('user.bill.type');
        //查看服务器
        $route->get('/buy/good/{id}', 'UserOrderController@buyGoodShow')->name('user.buy.good.show');
        //续费服务器
        $route->get('/buy/good/{id}/renewal', 'UserOrderController@buyGoodRenewal')->name('user.buy.good.renewal');
        //续费产品提交
        $route->post('/buy/good/renewal', 'UserOrderController@renewalGood')->name('user.renewal.good');

        //查看域名
        $route->get('/buy/domain/{id}', 'UserOrderController@buyDomainShow')->name('user.buy.domain.show');

        //续费域名
        $route->get('/buy/domain/{id}/renewal', 'UserOrderController@renewalDomain')->name('user.buy.domain.renewal');
        //续费域名提交
        $route->post('/buy/domain/renewal', 'UserOrderController@renewalDomainPost')->name('user.renewal.domain');

        //域名提交操作
        $route->post('/domain/handle/{id}', 'UserOrderController@domainHandle')->name('user.buy.domain.handle');

    });

    //搜索
    $route->group(['prefix' => 'search', 'as' => 'search.'], function ($route) {
        $route->get('/','SearchController@index')->name('search');
        $route->post('/list','SearchController@list')->name('list');
        $route->post('/item_list','SearchController@itemList')->name('item_list');
    });
});

?>
